package com.scs.application.modules.purchase.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.scs.application.core.entity.FlowEntity;
import com.scs.application.modules.upgrade.db.annotation.EntityClassAnnotation;
import com.scs.application.modules.upgrade.db.annotation.EntityFieldAnnotation;
import com.scs.application.modules.upgrade.db.annotation.EntityIndexAnnotation;
import com.scs.application.modules.upgrade.db.enums.EntityFieldType;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.Date;

/**
 * <p>
 * 采购订单
 * </p>
 */
@Data
@Accessors(chain = true)
@TableName("purchase_order")
@EntityClassAnnotation(remark = "采购订单表")
@EntityIndexAnnotation(ux = {"bus_key"}, ix = {"supplier_id"})
public class Order extends FlowEntity {


    // id ,在父类中处理

    @EntityFieldAnnotation(
            text = "供方ID",
            type = EntityFieldType.LONG,
            length = "",
            not_null = true,
            default_value = "",
            comment = "供方ID"
    )
    private String supplierId;
    @EntityFieldAnnotation(
            text = "in:purchase_order.id",
            type = EntityFieldType.LONG,
            length = "",
            not_null = false,
            default_value = "0",
            comment = ""
    )
    private String refId;

    @EntityFieldAnnotation(
            text = "来源业务单号",
            length = "30",
            not_null = false,
            default_value = "",
            comment = ""
    )
    private String refKey;

    @EntityFieldAnnotation(
            text = "来源业务主表",
            length = "30",
            not_null = false,
            default_value = "",
            comment = ""
    )
    private String refTable;

    @EntityFieldAnnotation(
            text = "供方名称",
            length = "100",
            not_null = true,
            default_value = "",
            comment = "供方名称"
    )
    private String supplierName;
    @EntityFieldAnnotation(
            text = "需求来源科室ID",
            type = EntityFieldType.LONG,
            length = "",
            not_null = true,
            default_value = "",
            comment = "需求来源科室ID"
    )
    private String deptIdDemand;


    @EntityFieldAnnotation(
            text = "结算类型",
            length = "10",
            not_null = true,
            default_value = "used"
    )
    private String settlementType;

    @EntityFieldAnnotation(
            text = "采购科室ID",
            type = EntityFieldType.LONG,
            length = "",
            default_value = "",
            comment = "采购科室ID"
    )
    private String deptId;

    @EntityFieldAnnotation(
            text = "采购科室名称",
            length = "30",
            default_value = "",
            comment = "采购科室名称"
    )
    private String deptName;


    @EntityFieldAnnotation(
            text = "需求来源科室",
            length = "30",
            not_null = true,
            default_value = "",
            comment = "需求来源科室"
    )
    private String deptNameDemand;

    @EntityFieldAnnotation(
            text = "业务单号",
            length = "20",
            not_null = true,
            default_value = "",
            comment = ""
    )
    private String busKey;

    @EntityFieldAnnotation(
            text = "业务日期",
            type = EntityFieldType.DATE,
            length = "",
            not_null = true,
            default_value = "",
            comment = ""
    )
    @JSONField(format = "yyyy-MM-dd")
    private Date busDate;

    @EntityFieldAnnotation(
            text = "业务主办人",
            length = "20",
            not_null = true,
            default_value = "",
            comment = ""
    )
    private String busUser;

    @EntityFieldAnnotation(
            text = "业务主办人工号",
            length = "20",
            not_null = false,
            default_value = "",
            comment = ""
    )
    private String busUserCode;

    @EntityFieldAnnotation(
            text = "要求到货日期",
            length = "",
            not_null = true,
            default_value = "",
            comment = ""
    )
    @JSONField(format = "yyyy-MM-dd")
    private Date dateLates;

    @EntityFieldAnnotation(
            text = "订单类型：B：购销（采购）；C：代销（寄售）",
            length = "10",
            not_null = false,
            default_value = "",
            comment = "订单类型"
    )
    private String poType;

    @EntityFieldAnnotation(
            text = "一物一码",
            not_null = true,
            default_value = "0",
            comment = "一物一码"
    )
    private Boolean flagOmoc;

    @EntityFieldAnnotation(
            text = "订单金额(元)",
            not_null = true,
            default_value = "0.0000",
            comment = "订单金额(元)"
    )
    private Double amount;

    @EntityFieldAnnotation(
            text = "备注",
            not_null = false,
            length = "200",
            default_value = "",
            comment = "备注"
    )
    private String remark;

    @EntityFieldAnnotation(
            text = "申请目标仓库ID",
            type = EntityFieldType.LONG,
            length = "",
            not_null = false,
            default_value = "",
            comment = "申请目标仓库ID"
    )
    private String warehouseId;

    @EntityFieldAnnotation(
            text = "申请目标仓库",
            length = "50",
            not_null = false,
            default_value = "",
            comment = "申请目标仓库"
    )
    private String warehouseName;


    @EntityFieldAnnotation(
            text = "推送标志 ",
            length = "",
            not_null = false,
            default_value = "0",
            comment = "推送标志"
    )
    private Boolean flagPushed;


    @EntityFieldAnnotation(
            text = "推送时间 ",
            length = "",
            not_null = false,
            comment = "推送时间"
    )
    private Date gmtPushed;


    @EntityFieldAnnotation(
            text = "订单关闭标志。0：未关闭，1：已关闭 ",
            length = "",
            not_null = true,
            default_value = "0",
            comment = "订单关闭标志"
    )
    private Boolean flagClosed;

    @EntityFieldAnnotation(
            text = "订单关闭原因 ",
            length = "",
            not_null = false,
            default_value = "",
            comment = "订单关闭原因"
    )
    private String closedReason;


    @EntityFieldAnnotation(
            text = "订单关闭时间 ",
            length = "",
            not_null = false,
            default_value = "",
            comment = "订单关闭时间"
    )
    private Date gmtClosed;

    @EntityFieldAnnotation(
            text = "关闭人姓名 ",
            length = "",
            not_null = false,
            default_value = "",
            comment = "关闭人姓名"
    )
    private String closeUser;

    @EntityFieldAnnotation(
            text = "入库状态 ",
            length = "",
            not_null = false,
            default_value = "0",
            comment = "0：未入库，1：部分入库，2：全部入库"
    )
    private String statusIn;

    @EntityFieldAnnotation(
            text = "同步状态 ",
            length = "",
            not_null = false,
            default_value = "0",
            comment = "0：待确认，1：待发货，2：已发货"
    )
    private String syncStatus;

    /**
     * 请领单号
     */
    @TableField(exist = false)
    private String applyKey;

     @EntityFieldAnnotation(
            text = "采购分类",
            length = "10",
            not_null = false,
            default_value = "matr",
            comment = "matr:耗材，reagent：试剂，drugs：药品,package：跟台包"
    )
    private String purchaseType;

    @EntityFieldAnnotation(
            text = "存储温度",
            not_null = false,
            length = "30",
            default_value = "",
            comment = "取自数据字典：matr_temperature.value"
    )
    private String temperature;

    @EntityFieldAnnotation(
            text = "试剂组id",
            type = EntityFieldType.LONG,
            length = "",
            not_null = false,
            default_value = ""
    )
    private String reagentTeamId;


    // 试剂组
    @TableField(exist = false)
    private String reagentTeamName;

    // 明细数量
    @TableField(exist = false)
    private int countDtl;

}
